import 'package:flutter/material.dart';
import '/page/index/index.dart';
import 'package:get/get.dart';
import '/router/router.dart';
import '/plugin/dio_new/dio_new.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'constants/extensions.dart';
import 'constants/screens.dart';

bool get currentIsDark => Screens.mediaQuery.platformBrightness.isDark;

const Color themeColor = Colors.deepPurple;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  HttpConfig dioConfig = HttpConfig(
    baseUrl: "http://owner-serv.yncce.cn/proprietor/ownerApi",
  );
  HttpClient client = HttpClient(dioConfig: dioConfig);
  Get.put<HttpClient>(client);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new GetMaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('en', 'US'), // English
        const Locale('zh', 'CN'), // Hebrew
        // ... other locales the app supports
      ],
      theme: ThemeData(
        brightness: Screens.mediaQuery.platformBrightness,
        primarySwatch: themeColor.swatch,
        textSelectionTheme: const TextSelectionThemeData(
          cursorColor: themeColor,
        ),
        visualDensity: VisualDensity.adaptivePlatformDensity,
        iconTheme: const IconThemeData(
          color: themeColor,
        ),
        appBarTheme: AppBarTheme(backgroundColor: themeColor),
      ),
      initialRoute: RouteConfig.main,
      getPages: RouteConfig.getPages,
      home: IndexPage(),
      builder: EasyLoading.init(),
    );
  }
}
